package cn.ggb.eduservice.controller;


import cn.ggb.commonutils.JwtUtils;
import cn.ggb.commonutils.R;
import cn.ggb.eduservice.entity.EduComment;
import cn.ggb.eduservice.service.EduCommentService;
import cn.ggb.servicebase.exceptionhandler.GuliException;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 评论 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-04-15
 */
@RestController
@RequestMapping("/eduservice/educomment")
public class EduCommentController {

    @Autowired
    private EduCommentService commentService;

    //分页查询课程评论
    @GetMapping("comment/{current}/{limit}")
    public R getComment(@PathVariable long current,
                        @PathVariable long limit){
        Page<EduComment> commentPage = new Page<>(current,limit);
        commentService.page(commentPage,null);
        //获取每页记录数
        List<EduComment> records = commentPage.getRecords();
        //获取总记录数
        long total = commentPage.getTotal();
        return R.ok().data("records",records).data("total",total);
    }

}

